#if !defined(MSDEVAPP_H__INCLUDED_)
#define MSDEVAPP_H__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class CMSDevApp  
{
public:
	static CMSDevApp &Instance()
	{
		static CMSDevApp instance;
		return instance;
	}

	void Attach(IApplication *pIApp)
	{
		ASSERT_NULL_OR_POINTER(pIApp, IApplication);

		m_pIApplication = pIApp;
	}

	IApplication *Detach()
	{
		IApplication *pIApp = m_pIApplication;
		m_pIApplication = NULL;

		return pIApp;
	}

	IApplication *operator -> ()
	{
		return m_pIApplication;
	}

	operator IApplication * ()
	{
		return m_pIApplication;
	}

	IApplication **operator & ()
	{
		return &m_pIApplication;
	}

public:
	~CMSDevApp()
	{
		if(m_pIApplication)
			m_pIApplication->Release();
	}

protected:
	CMSDevApp() : m_pIApplication(NULL) { }
	CMSDevApp(CMSDevApp &/*rRhs*/) { }
	CMSDevApp &operator = (CMSDevApp &/*rRhs*/) { return *this; }

private:
	IApplication *m_pIApplication;

};

#endif // !defined(MSDEVAPP_H__INCLUDED_)
